﻿#include<iostream>
#include<vector>
using namespace std;
#include"BRTree.h"
#include"MyMap.h"
#include"MySet.h"
void test_set()
{
	bit::set<int> s;
	s.insert(4);
	s.insert(1);
	s.insert(2);
	s.insert(3);
	s.insert(2);
	s.insert(0);
	s.insert(10);
	s.insert(5);

	bit::set<int>::iterator it = s.begin();
	while (it != s.end())
	{
		//*it += 1;

		cout << *it << " ";
		++it;
	}
	cout << endl;

	// key޸
	it = s.begin();
	// *it = 100;

	for (auto e : s)
	{
		cout << e << " ";
	}
	cout << endl;
}
void test_map()
{
	bit::map<string, string> dict;
	dict.insert(make_pair("sort", "排序"));
	dict.insert(make_pair("sort", "排序"));
	dict.insert(make_pair("left", "左边"));
	dict.insert(make_pair("right", "右边"));

	bit::map<string, string>::iterator it = dict.begin();
	while (it != dict.end())
	{
		// key޸
		//it->first += 'x';
		it->second += 'y';

		cout << it->first << ":" << it->second << endl;
		++it;
	}
	cout << endl;

	string arr[] = { "苹果", "西瓜", "苹果", "樱桃", "苹果", "樱桃", "苹果", "樱桃", "苹果" };
	bit::map<string, int> countMap;
	for (auto& e : arr)
	{
		countMap[e]++;
	}

	for (auto& kv : countMap)
	{
		cout << kv.first << ":" << kv.second << endl;
	}
	cout << endl;
}

int main()
{
	test_map();
	//const int N = 10000;
	//vector<int> v;
	//v.reserve(N);
	////srand(time(0));

	//for (size_t i = 0; i < N; i++)
	//{
	//	v.push_back(rand());
	//	//cout << v.back() << endl;
	//}
	//
	//BRTree<int, int> t;
	//for (auto e : v)
	//{
	//	t.Insert(make_pair(e, e));
	//	//cout << "Insert:" << e << "->" << t.IsBalance() << endl;
	//}
	//if (t._isBRTree())
	//{
	//	cout << "yes" << endl;
	//}
	//else
	//	cout << "no" << endl;
	////t.InOrder();
	////cout << "hello world" << endl;
	return 0;
}